package web.stu.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.*;
import web.stu.model.vo.TeacherCourseVO;

import java.util.List;

/**
 * @author administer
 * @description 针对表【teacher_course(教师授课表)】的数据库操作Mapper
 * @createDate 2025-05-13 19:55:10
 */
@Mapper
public interface TeacherCourseMapper {

    /**
     * 查询 教师授课表是否存在该班级id
     *
     * @param id
     * @return
     */
    @Select("select count(*) from teacher_course where class_id = #{id}")
    Integer countClassTeacherCourse(@Param("id") Integer id);


    /**
     * 查询 教师授课表是否有该记录
     *
     * @param classId
     * @param teacherId
     * @param courseId
     * @return
     */
    Integer countTeacherCourses(@Param("classId") Integer classId,
                                @Param("courseId") Integer courseId,
                                @Param("teacherId") Integer teacherId);

    /**
     * 分页查询 教师授课表
     *
     * @param classIds
     * @param courseIds
     * @param teacherIds
     * @return
     */
    IPage<TeacherCourseVO> pageTeacherCourse(@Param("classIds") List<Integer> classIds,
                                             @Param("courseIds") List<Integer> courseIds,
                                             @Param("teacherIds") List<Integer> teacherIds,
                                             Page<TeacherCourseVO> page);

    /**
     * 插入 给班级课程添加授课教师
     *
     * @param classId
     * @param teacherId
     * @param courseId
     * @return
     */
    @Insert("insert into teacher_course (teacher_id,course_id,class_id) values (#{teacherId},#{courseId},#{classId})")
    Integer insertTeacherCourse(@Param("classId") Integer classId,
                                @Param("courseId") Integer courseId,
                                @Param("teacherId") Integer teacherId);


    /**
     * 修改 根据课程id与班级id 修改授课表教师
     *
     * @param classId
     * @param teacherId
     * @param courseId
     * @return
     */
    Integer updateTeacherCourseByClassIdCourseId(@Param("classId") Integer classId,
                                                 @Param("courseId") Integer courseId,
                                                 @Param("teacherId") Integer teacherId);


    /**
     * 删除 删除教师授课记录
     *
     * @param classId
     * @param courseId
     * @param teacherId
     * @return
     */
    @Delete("delete from teacher_course where class_id = #{classId} and course_id = #{courseId} and teacher_id = #{teacherId}")
    Integer deleteTeacherCourse(@Param("classId") Integer classId, @Param("courseId") Integer courseId, @Param("teacherId") Integer teacherId);

}
